package com.sky.financelake.viewmodels.remote;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;

import com.sky.financelake.bean.dto.RPlateZjlxDto;
import com.sky.financelake.bean.dto.SimplePlateZjlxDto;
import com.sky.financelake.bean.dto.SimpleStockZjlxDto;
import com.sky.financelake.retrofit.ApiResponse;
import com.sky.financelake.retrofit.ZjlxRepository;
import com.sky.financelake.viewmodels.BaseViewModel;

import java.util.List;

public class ZjlxViewModel extends BaseViewModel {
    private MutableLiveData<ApiResponse<List<SimpleStockZjlxDto>>> stockZjlxLiveData;
    private MutableLiveData<ApiResponse<List<RPlateZjlxDto>>> plateZjlxRankLiveData;
    private MutableLiveData<ApiResponse<List<SimplePlateZjlxDto>>> plateZjlxLiveData;
    private ZjlxRepository zjlxRepository;

    public ZjlxViewModel() {
        zjlxRepository = ZjlxRepository.getInstance();
    }

    public ZjlxRepository getZjlxRepository() {
        return zjlxRepository;
    }

    public LiveData<ApiResponse<List<SimpleStockZjlxDto>>> getStockZjlxLiveData() {
        if (stockZjlxLiveData == null) {
            stockZjlxLiveData = new MutableLiveData<ApiResponse<List<SimpleStockZjlxDto>>>();
        }
        return stockZjlxLiveData;
    }

    public LiveData<ApiResponse<List<RPlateZjlxDto>>> getPlateZjlxRankLiveData() {
        if (plateZjlxRankLiveData == null) {
            plateZjlxRankLiveData = new MutableLiveData<ApiResponse<List<RPlateZjlxDto>>>();
        }
        return plateZjlxRankLiveData;
    }

    public LiveData<ApiResponse<List<SimplePlateZjlxDto>>> getPlateZjlxLiveData() {
        if (plateZjlxLiveData == null) {
            plateZjlxLiveData = new MutableLiveData<ApiResponse<List<SimplePlateZjlxDto>>>();
        }
        return plateZjlxLiveData;
    }


    public void getPlateZjlxRank(Integer days) {
        zjlxRepository.getPlateZjlxRank(plateZjlxRankLiveData, days);
    }

    public void getStockZjlx(String key) {
        zjlxRepository.getStockZjlx(stockZjlxLiveData, key);
    }

    public void getPlateZjlx(String key) {
        zjlxRepository.getPlateZjlx(plateZjlxLiveData, key);
    }
}
